import Vue from 'vue'
import VueRouter from 'vue-router'
import MyMain from '@/view/MyMain.vue'
import LOgin from '@/view/LOgin.vue'
import store from '@/store'
import Cookie from 'js-cookie'
Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    {
      path: '/',
      component: MyMain,
      name: 'Main', // 动态路由的父路由名称
      redirect: '/home',
      children: [] // 动态路由会添加到这里
    },
    { path: '/login', name: 'login', component: LOgin }
  ]
})

if (Cookie.get('menu')) {
  store.commit('addMenu', router)
}

export default router